#ifndef _TYPE_H
#define _TYPE_H

#include <stddef.h>
#include "stdint.h"			// Define standard integers.



typedef short  				int16;
typedef long 				int32;
typedef unsigned short		uint16;
typedef unsigned int		uint32;
typedef unsigned int		BOOL;
typedef unsigned short		WORD;

typedef short  				i16;
typedef long 				i32;
typedef long long			i64;

//typedef short  			s16;
//typedef long 				s32;
typedef long long			s64;

typedef unsigned long long	u64;


//typedef unsigned char  BOOLEAN;
typedef unsigned char		uint8;                    /* Unsigned  8 bit quantity                           */
typedef signed char			int8;                    /* Signed    8 bit quantity                           */

//typedef float				FP32;                     /* Single precision floating point                    */
//typedef double			FP64;                     /* Double precision floating point                    */

#define BYTE				uint8                     /* Define data types for backward compatibility ...   */
#define UBYTE				uint8                     /* ... to uC/OS V1.xx.  Not actually needed for ...   */
//#define WORD				INT16S                    /* ... uC/OS-II.                                      */
#define UWORD				uint16
#define DWORD 				uint32

#define LINT				signed long int

#define INT8U				uint8
#define INT16U				uint16
#define INT32U				uint32

typedef uint16_t uint16;
typedef uint8_t u8;
typedef uint64_t u64;
typedef uint32_t u32;
typedef uint16_t u16;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;


typedef unsigned int	OS_CPU_SR;                /* Define size of CPU status register (PSR = 32 bits) */

#if 0
#define TRUE				1
#define FALSE				0
#endif

#define true				1
#define false				0

//#define bool				u8
#define BOOLEAN				u8
	

#define StrBinaryByte(h,g,f,e,d,c,b,a)						((a<<0)+(b<<1)+(c<<2)+(d<<3)+(e<<4)+(f<<5)+(g<<6)+(h<<7))
#define StrBinaryWord(p,o,n,m,l,k,j,i,   h,g,f,e,d,c,b,a)	(((u16)StrBinaryByte(p,o,n,m,l,k,j,i) << 8) + StrBinaryByte(h,g,f,e,d,c,b,a))


#define VALID_FLAG			0x5A	// 有效标志
#define INVALID_FLAG		0xA5	// 无效标志
#define VALID_FLAG_U32		0xAA551357
#define VALID_FLAG_U16		0xAA55
#define INVALID_FLAG_U32	0x00

#define PI_					3.1415926

#define ARRAY_SIZE(arr)		(sizeof(arr) / sizeof((arr)[0]))

#ifndef BIT0			
#define BIT0			(0x0001)
#define BIT1			(0x0002)
#define BIT2			(0x0004)
#define BIT3			(0x0008)
#define BIT4			(0x0010)
#define BIT5			(0x0020)
#define BIT6			(0x0040)
#define BIT7			(0x0080)
#define BIT8			(0x0100)
#define BIT9			(0x0200)
#define BITA			(0x0400)
#define BITB			(0x0800)
#define BITC			(0x1000)
#define BITD			(0x2000)
#define BITE			(0x4000)
#define BITF			(0x8000)
#endif

#define BIT10			(0x00010000)
#define BIT11			(0x00020000)
#define BIT12			(0x00040000)
#define BIT13			(0x00080000)
#define BIT14			(0x00100000)
#define BIT15			(0x00200000)
#define BIT16			(0x00400000)
#define BIT17			(0x00800000)
#define BIT18			(0x01000000)
#define BIT19			(0x02000000)
#define BIT1A			(0x04000000)
#define BIT1B			(0x08000000)
#define BIT1C			(0x10000000)
#define BIT1D			(0x20000000)
#define BIT1E			(0x40000000)
#define BIT1F			(0x80000000)


typedef union
{
	u8 byte[2];
	u16 val;
} u16_byte;
typedef union
{
	u8 byte[4];
	u32 val;
} u32_byte;
typedef union
{
	u8 byte[2];
	i16 val;
} i16_byte;
typedef union
{
	u8 byte[4];
	i32 val;
} i32_byte;
typedef union
{
	u16 word[2];
	u32 val;
}u32u16_type;
typedef union
{
	u32 dword[2];
	u16 word[4];
	u8 byte[8];
	unsigned long long val;
}u64_type;

// 实虚部结构
struct REAL_RX_S{
	float	R;			//实部
	float	X;			//虚部
};

// 系统时钟
typedef	struct	
{
	u8 second;
	u8 minute;
	u8 hour;
	u8 day;
	u8 month;
	u8 year;
	u8 week;
}Clock_645_Type;


typedef struct
{
	uint8 Second;
	uint8 Minute;
	uint8 Hour;
	uint8 Date;
	uint8 Month;
	uint8 Year;
}TIME_YMDHMS_TYPE;


typedef struct
{
	uint8 second;
	uint8 minute;
	uint8 hour;
	uint8 day;
	uint8 month;
	uint8 year;
}CLOCK_YMDHMS_TYPE;

typedef	struct
{
	uint8 second;
	uint8 minute;
	uint8 hour;
	uint8 day;
	uint8 month;
	uint8 year;
	uint8 week;
	uint8 reserv;
    uint16 ms;
}Clock_Type;

typedef struct
{
	uint8 second;
	uint8 minute;
	uint8 hour;
	uint8 day;
	uint8 month;
	uint8 year;
	uint16 ms;
}CLOCK_SHORT_TYPE;

typedef struct 
{
	u8 second;
	u8 minute;
	u8 hour;
	u8 day;
	u8 month;
	u8 year;
}clk_ymdhms_type;


#endif

